[id].vue 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div id="newsList">
  3. <!-- 头部 -->
  4. <templateHead></templateHead>
  5. <!-- 菜单 -->
  6. <templateMenu></templateMenu>
  7. <div v-for="(item,index) in templateData" :key="index">
  8. <!--1.广告通栏-->
  9. <div v-if="item.sectorName=='adSector'">
  10. <templateAd :skinId="skinId" :adData="adData" :adTag="item.ad.ad_tag"></templateAd>
  11. </div>
  12. <!-- 2.搜索列表 -->
  13. <div v-if="item.sectorName=='searchListSector'">
  14. <templateSearch :skinId="skinId" :templateData="item.componentList"></templateSearch>
  15. </div>
  16. </div>
  17. <!-- 底部 -->
  18. <templateFoot></templateFoot>
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. //0.加载全局模板组件 start---------------------------------------->
  23. //0.1 全局通栏
  24. import templateHead from '@/components/template/sector/head/1200x200/1.vue'
  25. import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
  26. import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
  27. //0.2.1 广告组件
  28. import templateAd from '@/components/template/sector/body/ad/1200x90/1.vue'
  29. //0.2.2 搜索组件
  30. import templateSearch from '@/components/template/sector/body/search/list/1200x1300/1.vue'
  31. //0.加载全局模板组件 end---------------------------------------->
  32. //1.获得基本信息单元 start---------------------------------------->
  33. //1.1获得页面依赖
  34. import { ref, onMounted } from 'vue';
  35. //1.2获得pinia源
  36. import { useTemplateBaseStore } from '@/stores/templateBase'
  37. const templateBaseStore:any = useTemplateBaseStore()
  38. //1.3获得该页的皮肤id - 在每个组件中也是同样的获得方法
  39. const skinId = ref<number>(0)
  40. const websiteId = ref<number>(0)
  41. //1.4获得站点基本信息
  42. const responseStatus:any = await requestDataPromise('/web/getWebsiteAllinfo', {
  43. method: 'GET',
  44. query: {
  45. 'link_textnum':24,
  46. 'link_imgnum':18,
  47. 'link_footnum':4
  48. },
  49. });
  50. if (responseStatus.code == 200) {
  51. //0.3.1设置站点基本信息
  52. templateBaseStore.setWebSiteInfo(responseStatus.data)
  53. websiteId.value = responseStatus.data.website_head.id;//获得网站id
  54. //0.3.2设置皮肤id
  55. skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
  56. console.log("当前的网站id:"+responseStatus.data.website_head.id)
  57. //0.3.3设置seo信息
  58. let seoTitle = templateBaseStore.webSiteInfo.website_head.title;
  59. let seoDescription = templateBaseStore.webSiteInfo.website_head.description;
  60. let seoKeywords = templateBaseStore.webSiteInfo.website_head.keywords;
  61. let seoSuffix = templateBaseStore.webSiteInfo.website_head.suffix;
  62. let seoName = templateBaseStore.webSiteInfo.website_head.website_name;
  63. useHead({
  64. title: seoTitle + "_" + seoSuffix,
  65. meta: [
  66. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  67. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  68. ]
  69. });
  70. }
  71. //1.获得基本信息单元 end---------------------------------------->
  72. //2.页面数据 start---------------------------------------->
  73. //2.1获得页面数据
  74. const response = await requestDataPromise('/client/indexData', {
  75. method: 'POST',
  76. body: {
  77. 'website_id':websiteId.value,
  78. 'getpage':'search'
  79. },
  80. });
  81. //页面数据
  82. const templateData = response.data.template.search;
  83. console.log(templateData)
  84. //广告数据
  85. const adData = ref<any[]>([]);
  86. adData.value.push(response.data.ad.top)
  87. for(let item of response.data.ad.aloneArticle){
  88. adData.value.push(item)
  89. }
  90. templateBaseStore.setAdList(adData.value)
  91. //2.页面数据 end---------------------------------------->
  92. </script>
  93. <style lang="less" scoped>
  94. </style>